package com.util;

import com.mchange.v2.c3p0.ComboPooledDataSource;
import org.junit.Test;

import java.beans.PropertyVetoException;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.ResourceBundle;

public class MyC3p0 {
    @Test
    public void T1() throws Exception {
        ResourceBundle jdbc = ResourceBundle.getBundle("jdbc");
        //创建数据源
        ComboPooledDataSource dataSource = new ComboPooledDataSource();
        //设置数据库连接参数
        dataSource.setDriverClass(jdbc.getString("jdbc.driver"));
        dataSource.setJdbcUrl(jdbc.getString("jdbc.url"));
        dataSource.setUser(jdbc.getString("jdbc.username"));
        dataSource.setPassword(jdbc.getString("jdbc.password"));
        //获得连接对象
        Connection connection = dataSource.getConnection();
        System.out.println(connection);
    }
}
